package org.lee.common.util;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * DateUtil
 *
 * @author dralee
 * @date 2021-11-23 17:43:47
 **/
public class DateUtil {

    public static long getTimeStamp(LocalDateTime localDateTime) {
        ZoneId zoneId = ZoneId.systemDefault();
        Instant instant = localDateTime.atZone(zoneId).toInstant();
        return instant.toEpochMilli();
    }

    public static Date fromLocalDateTime(LocalDateTime localDateTime) {
        return new Date(getTimeStamp(localDateTime));
    }
}
